package com.sc.nft.service.impl;

import com.google.common.collect.Lists;
import com.sc.nft.dao.MallActivityShareSpecsDao;
import com.sc.nft.entity.MallActivityShareSpecs;
import com.sc.nft.entity.dto.AdminMallActivityShareSpecsDetailDTO;
import com.sc.nft.entity.vo.EditMallActivityShareSpecsVO;
import com.sc.nft.service.MallActivityShareSpecsService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 分享购活动规格 服务实现类
 * </p>
 *
 * @author ligen
 * @since 2023-12-11
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class MallActivityShareSpecsServiceImpl implements MallActivityShareSpecsService {

    private final MallActivityShareSpecsDao mallActivityShareSpecsDao;

    /**
     * 批量创建分享购活动规格
     *
     * @param mallActivityShareSpecsVOList
     */
    @Override
    public void createList(List<EditMallActivityShareSpecsVO> mallActivityShareSpecsVOList, Long activityShareId, Long activityId) {
        List<MallActivityShareSpecs> mallActivityShareSpecsList = Lists.newArrayList();
        for (EditMallActivityShareSpecsVO editMallActivityShareSpecsVO : mallActivityShareSpecsVOList) {
            MallActivityShareSpecs mallActivityShareSpecs = new MallActivityShareSpecs();
            mallActivityShareSpecs.setActivityShareId(activityShareId);
            mallActivityShareSpecs.setActivityId(activityId);
            mallActivityShareSpecs.setActivitySpecsId(editMallActivityShareSpecsVO.getActivitySpecsId());
            mallActivityShareSpecs.setSalesPrice(editMallActivityShareSpecsVO.getShareSalesPrice());
            mallActivityShareSpecsList.add(mallActivityShareSpecs);
        }
        mallActivityShareSpecsDao.saveBatch(mallActivityShareSpecsList);
    }

    /**
     * 获取分享活动下活动规格
     *
     * @param activityShareId
     * @return
     */
    @Override
    public List<AdminMallActivityShareSpecsDetailDTO> getAdminShareSpecsDetailDTOListByShareId(Long activityShareId) {
        return mallActivityShareSpecsDao.getAdminShareSpecsDetailDTOListByShareId(activityShareId);
    }

    /**
     * 获取分享活动下活动规格
     *
     * @param activityShareId
     * @return
     */
    @Override
    public List<MallActivityShareSpecs> getMallActivityShareSpecs(Long activityShareId) {
        return mallActivityShareSpecsDao.getList(activityShareId);
    }

    /**
     * 获取分享活动下活动规格
     *
     * @param activityShareId
     * @return
     */
    @Override
    public MallActivityShareSpecs getMallActivityShareSpecs(Long activityShareId, Long activityId, Long activitySpecsId) {
        return mallActivityShareSpecsDao.getMallActivityShareSpecs(activityShareId, activityId, activitySpecsId);
    }
}
